package com.goods.Service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.goods.Mapper.GoodsMapper;
import com.goods.Service.GoodsService;
import com.goods.Pojo.Goods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsServiceImpl implements GoodsService {
    @Autowired
    private GoodsMapper goodsMapper;
    @Override
    public void AddGoods(Goods goods) {
        goodsMapper.AddGoods(goods);
    }

    @Override
    public void UpdateGoods(Goods goods) {
        goodsMapper.UpdateGoods(goods);
    }

    @Override
    public PageInfo<Goods> SearchGoods(Integer pageNum, Integer pageSize, String goodsName, String factory) {
        PageHelper.startPage(pageNum,pageSize);
        List<Goods> goodsList=goodsMapper.SearchGoods(goodsName,factory);
        PageInfo<Goods> pageInfo=new PageInfo<>(goodsList);
        return pageInfo;
    }

    @Override
    public void DelGoods(Integer id) {
        goodsMapper.DelGoods(id);
    }

    @Override
    public Goods getByid(Integer id) {
        return goodsMapper.getByid(id);
    }

    @Override
    public List<Goods> searchlist() {
        return goodsMapper.searchlist();
    }
}
